#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include <QWidget>
#include <QPushButton>
#include <QLineEdit>
#include "sessionfriendarea.h"
#include "messageshowarea.h"
#include "messageeditarea.h"
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWidget;
}
QT_END_NAMESPACE

class MainWidget : public QWidget
{
    Q_OBJECT

public:
    enum class ActiveTab
    {
        SESSION,
        FRIEND,
        APPLY
    };



    static MainWidget* getInstance();

    ~MainWidget();

    //初始化函数
    void initMainWindow();
    void initLeftWindow();
    void initMidWindow();
    void initRightWindow();
    void initSignalSlot();
    //槽函数
    void switchToSession();
    void switchToFriend();
    void switchToApply();
    void switchSession(const QString& userId);
    //从dataCenter中获取资源函数
    void loadSessionList();
    void loadFriendList();
    void loadApplyList();
    void loadRecentMessage(const QString& sessionId);
    //从本地内存中更新资源
    void updateSessionList();
    void updateFriendList();
    void updateApplyList();
    void updateRencentMessage(const QString& sessionId);

    void initWebSocket();

    messageShowArea* getMessageShowArea()
    {return MShowArea;}
private:
    MainWidget(QWidget *parent = nullptr);
    static MainWidget* instance;


    Ui::MainWidget *ui;
    QWidget* windowLeft;
    QWidget* windowMid;
    QWidget* windowRight;

    QPushButton* userAvatar;
    QPushButton* sessionTabBtn;
    QPushButton* friendTabBtn;
    QPushButton* applyTabBtn;
    ActiveTab activeTab = ActiveTab::SESSION;

    QLineEdit* searchEdit;
    QPushButton* addFriendBtn;
    sessionFriendArea* SFriendArea;

    QLabel* sessionTitleLabel;
    QPushButton* sessionExtraButton;
    messageShowArea* MShowArea;
    messageEditArea* MEditArea;
};
#endif // MAINWIDGET_H
